package com.ruoyi.project.mydy.permovrelation.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.mydy.permovrelation.domain.DlPermovRelation;
import com.ruoyi.project.mydy.permovrelation.service.IDlPermovRelationService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 导演职员与电影关系映射Controller
 * 
 * @author mhg
 * @date 2021-10-07
 */
@Controller
@RequestMapping("/mydy/permovrelation")
public class DlPermovRelationController extends BaseController
{
    private String prefix = "mydy/permovrelation";

    @Autowired
    private IDlPermovRelationService dlPermovRelationService;

    @RequiresPermissions("mydy:permovrelation:view")
    @GetMapping()
    public String permovrelation()
    {
        return prefix + "/permovrelation";
    }

    /**
     * 查询导演职员与电影关系映射列表
     */
    @RequiresPermissions("mydy:permovrelation:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DlPermovRelation dlPermovRelation)
    {
        startPage();
        List<DlPermovRelation> list = dlPermovRelationService.selectDlPermovRelationList(dlPermovRelation);
        return getDataTable(list);
    }

    /**
     * 导出导演职员与电影关系映射列表
     */
    @RequiresPermissions("mydy:permovrelation:export")
    @Log(title = "导演职员与电影关系映射", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DlPermovRelation dlPermovRelation)
    {
        List<DlPermovRelation> list = dlPermovRelationService.selectDlPermovRelationList(dlPermovRelation);
        ExcelUtil<DlPermovRelation> util = new ExcelUtil<DlPermovRelation>(DlPermovRelation.class);
        return util.exportExcel(list, "导演职员与电影关系映射数据");
    }

    /**
     * 新增导演职员与电影关系映射
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存导演职员与电影关系映射
     */
    @RequiresPermissions("mydy:permovrelation:add")
    @Log(title = "导演职员与电影关系映射", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DlPermovRelation dlPermovRelation)
    {
        return toAjax(dlPermovRelationService.insertDlPermovRelation(dlPermovRelation));
    }

    /**
     * 修改导演职员与电影关系映射
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        DlPermovRelation dlPermovRelation = dlPermovRelationService.selectDlPermovRelationById(id);
        mmap.put("dlPermovRelation", dlPermovRelation);
        return prefix + "/edit";
    }

    /**
     * 修改保存导演职员与电影关系映射
     */
    @RequiresPermissions("mydy:permovrelation:edit")
    @Log(title = "导演职员与电影关系映射", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DlPermovRelation dlPermovRelation)
    {
        return toAjax(dlPermovRelationService.updateDlPermovRelation(dlPermovRelation));
    }

    /**
     * 删除导演职员与电影关系映射
     */
    @RequiresPermissions("mydy:permovrelation:remove")
    @Log(title = "导演职员与电影关系映射", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(dlPermovRelationService.deleteDlPermovRelationByIds(ids));
    }
}
